package com.cgwx.commonutils.math.function;

/**
 * @author GaoWei
 * @Date 2021/8/6 - 9:28
 */
public class SumFunction implements Function
{
    @Override
    public double of(double[] d, int numParam)
    {
        double sum = 0.0D;
        for (int i = 0; i < numParam; i++)
        {
            sum += d[i];
        }
        return sum;
    }

    @Override
    public boolean acceptNumParam(int numParam)
    {
        return numParam > 0;
    }

    public String toString()
    {
        return "sum(x1, x2, ..., xn)";
    }
}
